﻿using MiniFox.Web.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniFox.Platform.Applications.Web
{
    /// <summary>
    /// 带授权的控制器
    /// </summary>
    /// <typeparam name="T">服务组件类型</typeparam>
    public abstract class AuthorizedController<T> : MvcControllerBase
    {
        T _component;
        /// <summary>
        /// 
        /// </summary>
        protected virtual T Component
        {
            get
            {
                if (_component == null)
                {
                    if (this.User != null)
                        _component = this.Container.GetComponent<T>(this.User);
                }
                return _component;
            }
        }
    }
}
